package com.kanche.bigbaby.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.kanche.bigbaby.R;
import com.kanche.bigbaby.adapter.BasePageVPAdapter;
import com.kanche.bigbaby.support.base.BaseFragment;
import com.kanche.bigbaby.support.base.BasePage;
import com.kanche.bigbaby.support.tab_wechat.WechatTab;
import com.kanche.bigbaby.support.viewpager_noscroll.CustomViewPager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Chenshao_Young on 15/5/18.
 */
public class DazhixinFragment extends BaseFragment {
    View view;

    String [] tabTitles = null;
    int from = 1;

    CustomViewPager vp;
    WechatTab tabs;
    List<BasePage> basePageList = new ArrayList<>();


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_dazhixin,container,false);
        vp = justFindIt(view, R.id.vp_dazhixin);
        tabs = justFindIt(view,R.id.tabs_dazhixin);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if(1 == from){
            tabTitles = getResources().getStringArray(R.array.titles_up_dazhixin);
        } else {
            tabTitles = getResources().getStringArray(R.array.titles_down_dazhixin);
        }

        basePageList.clear();
        for (String s : tabTitles){
            basePageList.add(new SmListViewPage(getActivity(), s));
        }
        vp.setAdapter(new BasePageVPAdapter(basePageList, tabTitles));

        tabs.setViewPager(vp);
    }

    public static DazhixinFragment newInstance(){
        Bundle arg = new Bundle();
        arg.putString(FRAGMENT_NAME,DazhixinFragment.class.getSimpleName());

        DazhixinFragment fragment = new DazhixinFragment();
        fragment.setArguments(arg);
        return fragment;
    }
}
